package com.sun.dingDing.controller;

import com.sun.dingDing.entity.LinkEntity;
import com.sun.dingDing.entity.MarkdownEntity;
import com.sun.dingDing.entity.TextEntity;
import com.sun.dingDing.utils.DingDingUtils;
import com.sun.dingDing.utils.GetSign;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/dingding")
public class DingDingController {

    @PostMapping(value = "/sendText")
    public boolean sendTextMessage(@RequestBody TextEntity text) {
        return DingDingUtils.sendToDingDing(text.getJSONObjectString(), GetSign.getSign());
    }

    @PostMapping(value = "/sendMarkdown")
    public boolean sendMarkdownMessage(@RequestBody MarkdownEntity markdownEntity) {
        return DingDingUtils.sendToDingDing(markdownEntity.getJSONObjectString(), GetSign.getSign());
    }

    @PostMapping(value = "/sendLink")
    public boolean sendLinkMessage(@RequestBody LinkEntity linkEntity) {
        return DingDingUtils.sendToDingDing(linkEntity.getJSONObjectString(), GetSign.getSign());
    }
}
